home *** CD-ROM | disk | FTP | other *** search
/ The Arsenal Files 8 / The Arsenal Files Collection #8 (Arsenal Computer) (1996).ISO / g_quake / ultqsrc.zip / CLIENT.QC < prev    next >
Text File  |  1996-10-02  |  41KB  |  1,569 lines

  1. // prototypes
  2. void () W_WeaponFrame;
  3. void() W_SetCurrentAmmo;
  4. void() player_pain;
  5. void() player_stand1;
  6. void (vector org) spawn_tfog;
  7. void (vector org, entity death_owner) spawn_tdeath;
  8. void() play_dog_leap1;
  9. // kicking
  10. void() PlayerTouch;
  11.  
  12. float   modelindex_eyes, modelindex_player, modelindex_dog;
  13. /*
  14. =============================================================================
  15.  
  16.                 LEVEL CHANGING / INTERMISSION
  17.  
  18. =============================================================================
  19. */
  20.  
  21. float    intermission_running;
  22. float    intermission_exittime;
  23.  
  24. /*QUAKED info_intermission (1 0.5 0.5) (-16 -16 -16) (16 16 16)
  25. This is the camera point for the intermission.
  26. Use mangle instead of angle, so you can set pitch or roll as well as yaw.  'pitch roll yaw'
  27. */
  28. void() info_intermission =
  29. {
  30. };
  31.  
  32.  
  33.  
  34. void() SetChangeParms =
  35. {
  36. // remove items
  37.     self.items = self.items - (self.items & 
  38.     (IT_KEY1 | IT_KEY2 | IT_INVISIBILITY | IT_INVULNERABILITY | IT_SUIT | IT_QUAD) );
  39. // add time to next level for proper mana maintainance
  40.         self.init_mana = self.init_mana - time;
  41.         parm10 = self.init_mana;
  42.         parm11 = self.exp;
  43. // cap super health
  44.     if (self.health > 100)
  45.         self.health = 100;
  46.     if (self.health < 50)
  47.         self.health = 50;
  48.     parm1 = self.items;
  49.     parm2 = self.health;
  50.     parm3 = self.armorvalue;
  51.     if (self.ammo_shells < 25)
  52.         parm4 = 25;
  53.     else
  54.         parm4 = self.ammo_shells;
  55.     parm5 = self.ammo_nails;
  56.     parm6 = self.ammo_rockets;
  57.     parm7 = self.ammo_cells;
  58.     parm8 = self.weapon;
  59.     parm9 = self.armortype * 100;
  60.         parm12 = self.amtaxe;
  61. };
  62.  
  63. void() SetNewParms =
  64. {
  65.         parm1 = IT_SHOTGUN | IT_AXE | IT_SNIPERGUN;
  66.     parm2 = 100;
  67.     parm3 = 0;
  68.     parm4 = 25;
  69.     parm5 = 0;
  70.     parm6 = 0;
  71.     parm6 = 0;
  72.     parm8 = 1;
  73.     parm9 = 0;
  74.         parm10 = time;
  75.         if (deathmatch)
  76.                 parm11 = 900;
  77.         else parm11 = 0;
  78.         parm12 = 1;
  79. };
  80.  
  81. void() DecodeLevelParms =
  82. {
  83.     if (serverflags)
  84.     {
  85.         if (world.model == "maps/start.bsp")
  86.             SetNewParms ();        // take away all stuff on starting new episode
  87.     }
  88.     
  89.     self.items = parm1;
  90.     self.health = parm2;
  91.     self.armorvalue = parm3;
  92.     self.ammo_shells = parm4;
  93.     self.ammo_nails = parm5;
  94.     self.ammo_rockets = parm6;
  95.     self.ammo_cells = parm7;
  96.     self.weapon = parm8;
  97.     self.armortype = parm9 * 0.01;
  98.         self.init_mana = parm10;
  99.         if (deathmatch)
  100.                 self.exp = 900000;
  101.         else self.exp = parm11;
  102.         self.amtaxe = parm12;
  103. };
  104.  
  105. /*
  106. ============
  107. FindIntermission
  108.  
  109. Returns the entity to view from
  110. ============
  111. */
  112. entity() FindIntermission =
  113. {
  114.     local    entity spot;
  115.     local    float cyc;
  116.  
  117. // look for info_intermission first
  118.     spot = find (world, classname, "info_intermission");
  119.     if (spot)
  120.     {    // pick a random one
  121.         cyc = random() * 4;
  122.         while (cyc > 1)
  123.         {
  124.             spot = find (spot, classname, "info_intermission");
  125.             if (!spot)
  126.                 spot = find (spot, classname, "info_intermission");
  127.             cyc = cyc - 1;
  128.         }
  129.         return spot;
  130.     }
  131.  
  132. // then look for the start position
  133.     spot = find (world, classname, "info_player_start");
  134.     if (spot)
  135.         return spot;
  136.     
  137. // testinfo_player_start is only found in regioned levels
  138.     spot = find (world, classname, "testplayerstart");
  139.     if (spot)
  140.         return spot;
  141.     
  142.     objerror ("FindIntermission: no spot");
  143. };
  144.  
  145.  
  146. string nextmap;
  147. void() GotoNextMap =
  148. {
  149.     if (cvar("samelevel"))    // if samelevel is set, stay on same level
  150.         changelevel (mapname);
  151.     else
  152.         changelevel (nextmap);
  153. };
  154.  
  155.  
  156. void() ExitIntermission =
  157. {
  158. // skip any text in deathmatch
  159.     if (deathmatch)
  160.     {
  161.         GotoNextMap ();
  162.         return;
  163.     }
  164.     
  165.     intermission_exittime = time + 1;
  166.     intermission_running = intermission_running + 1;
  167.  
  168. //
  169. // run some text if at the end of an episode
  170. //
  171.     if (intermission_running == 2)
  172.     {
  173.         if (world.model == "maps/e1m7.bsp")
  174.         {
  175.             WriteByte (MSG_ALL, SVC_CDTRACK);
  176.             WriteByte (MSG_ALL, 2);
  177.             WriteByte (MSG_ALL, 3);
  178.             if (!cvar("registered"))
  179.             {
  180.                 WriteByte (MSG_ALL, SVC_FINALE);
  181.                 WriteString (MSG_ALL, "As the corpse of the monstrous entity\nChthon sinks back into the lava whence\nit rose, you grip the Rune of Earth\nMagic tightly. Now that you have\nconquered the Dimension of the Doomed,\nrealm of Earth Magic, you are ready to\ncomplete your task in the other three\nhaunted lands of Quake. Or are you? If\nyou don't register Quake, you'll never\nknow what awaits you in the Realm of\nBlack Magic, the Netherworld, and the\nElder World!");
  182.             }
  183.             else
  184.             {
  185.                 WriteByte (MSG_ALL, SVC_FINALE);
  186.                 WriteString (MSG_ALL, "As the corpse of the monstrous entity\nChthon sinks back into the lava whence\nit rose, you grip the Rune of Earth\nMagic tightly. Now that you have\nconquered the Dimension of the Doomed,\nrealm of Earth Magic, you are ready to\ncomplete your task. A Rune of magic\npower lies at the end of each haunted\nland of Quake. Go forth, seek the\ntotality of the four Runes!");
  187.             }
  188.             return;
  189.         }
  190.         else if (world.model == "maps/e2m6.bsp")
  191.         {
  192.             WriteByte (MSG_ALL, SVC_CDTRACK);
  193.             WriteByte (MSG_ALL, 2);
  194.             WriteByte (MSG_ALL, 3);
  195.  
  196.             WriteByte (MSG_ALL, SVC_FINALE);
  197.             WriteString (MSG_ALL, "The Rune of Black Magic throbs evilly in\nyour hand and whispers dark thoughts\ninto your brain. You learn the inmost\nlore of the Hell-Mother; Shub-Niggurath!\nYou now know that she is behind all the\nterrible plotting which has led to so\nmuch death and horror. But she is not\ninviolate! Armed with this Rune, you\nrealize that once all four Runes are\ncombined, the gate to Shub-Niggurath's\nPit will open, and you can face the\nWitch-Goddess herself in her frightful\notherworld cathedral.");
  198.             return;
  199.         }
  200.         else if (world.model == "maps/e3m6.bsp")
  201.         {
  202.             WriteByte (MSG_ALL, SVC_CDTRACK);
  203.             WriteByte (MSG_ALL, 2);
  204.             WriteByte (MSG_ALL, 3);
  205.  
  206.             WriteByte (MSG_ALL, SVC_FINALE);
  207.             WriteString (MSG_ALL, "The charred viscera of diabolic horrors\nbubble viscously as you seize the Rune\nof Hell Magic. Its heat scorches your\nhand, and its terrible secrets blight\nyour mind. Gathering the shreds of your\ncourage, you shake the devil's shackles\nfrom your soul, and become ever more\nhard and determined to destroy the\nhideous creatures whose mere existence\nthreatens the souls and psyches of all\nthe population of Earth.");
  208.             return;
  209.         }
  210.         else if (world.model == "maps/e4m7.bsp")
  211.         {
  212.             WriteByte (MSG_ALL, SVC_CDTRACK);
  213.             WriteByte (MSG_ALL, 2);
  214.             WriteByte (MSG_ALL, 3);
  215.  
  216.             WriteByte (MSG_ALL, SVC_FINALE);
  217.             WriteString (MSG_ALL, "Despite the awful might of the Elder\nWorld, you have achieved the Rune of\nElder Magic, capstone of all types of\narcane wisdom. Beyond good and evil,\nbeyond life and death, the Rune\npulsates, heavy with import. Patient and\npotent, the Elder Being Shub-Niggurath\nweaves her dire plans to clear off all\nlife from the Earth, and bring her own\nfoul offspring to our world! For all the\ndwellers in these nightmare dimensions\nare her descendants! Once all Runes of\nmagic power are united, the energy\nbehind them will blast open the Gateway\nto Shub-Niggurath, and you can travel\nthere to foil the Hell-Mother's plots\nin person.");
  218.             return;
  219.         }
  220.  
  221.         GotoNextMap();
  222.     }
  223.     
  224.     if (intermission_running == 3)
  225.     {
  226.         if (!cvar("registered"))
  227.         {    // shareware episode has been completed, go to sell screen
  228.             WriteByte (MSG_ALL, SVC_SELLSCREEN);
  229.             return;
  230.         }
  231.         
  232.         if ( (serverflags&15) == 15)
  233.         {
  234.             WriteByte (MSG_ALL, SVC_FINALE);
  235.             WriteString (MSG_ALL, "Now, you have all four Runes. You sense\ntremendous invisible forces moving to\nunseal ancient barriers. Shub-Niggurath\nhad hoped to use the Runes Herself to\nclear off the Earth, but now instead,\nyou will use them to enter her home and\nconfront her as an avatar of avenging\nEarth-life. If you defeat her, you will\nbe remembered forever as the savior of\nthe planet. If she conquers, it will be\nas if you had never been born.");
  236.             return;
  237.         }
  238.         
  239.     }
  240.  
  241.     GotoNextMap();
  242. };
  243.  
  244. /*
  245. ============
  246. IntermissionThink
  247.  
  248. When the player presses attack or jump, change to the next level
  249. ============
  250. */
  251. void() IntermissionThink =
  252. {
  253.     if (time < intermission_exittime)
  254.         return;
  255.  
  256.     if (!self.button0 && !self.button1 && !self.button2)
  257.         return;
  258.     
  259.     ExitIntermission ();
  260. };
  261.  
  262. void() execute_changelevel =
  263. {
  264.     local entity    pos;
  265.  
  266.     intermission_running = 1;
  267.     
  268. // enforce a wait time before allowing changelevel
  269.     if (deathmatch)
  270.         intermission_exittime = time + 5;
  271.     else
  272.         intermission_exittime = time + 2;
  273.  
  274.     WriteByte (MSG_ALL, SVC_CDTRACK);
  275.     WriteByte (MSG_ALL, 3);
  276.     WriteByte (MSG_ALL, 3);
  277.     
  278.     pos = FindIntermission ();
  279.  
  280.     other = find (world, classname, "player");
  281.     while (other != world)
  282.     {
  283.         other.view_ofs = '0 0 0';
  284.         other.angles = other.v_angle = pos.mangle;
  285.         other.fixangle = TRUE;        // turn this way immediately
  286.         other.nextthink = time + 0.5;
  287.         other.takedamage = DAMAGE_NO;
  288.         other.solid = SOLID_NOT;
  289.         other.movetype = MOVETYPE_NONE;
  290.         other.modelindex = 0;
  291.         setorigin (other, pos.origin);
  292.         other = find (other, classname, "player");
  293.     }    
  294.  
  295.     WriteByte (MSG_ALL, SVC_INTERMISSION);
  296. };
  297.  
  298.  
  299. void() changelevel_touch =
  300. {
  301.     local entity    pos;
  302.  
  303.     if (other.classname != "player")
  304.         return;
  305.  
  306.     if (cvar("noexit"))
  307.     {
  308.         T_Damage (other, self, self, 50000);
  309.         return;
  310.     }
  311.     bprint (other.netname);
  312.     bprint (" exited the level\n");
  313.     
  314.     nextmap = self.map;
  315.  
  316.     SUB_UseTargets ();
  317.  
  318.     if ( (self.spawnflags & 1) && (deathmatch == 0) )
  319.     {    // NO_INTERMISSION
  320.         GotoNextMap();
  321.         return;
  322.     }
  323.     
  324.     self.touch = SUB_Null;
  325.  
  326. // we can't move people right now, because touch functions are called
  327. // in the middle of C movement code, so set a think time to do it
  328.     self.think = execute_changelevel;
  329.     self.nextthink = time + 0.1;
  330. };
  331.  
  332. /*QUAKED trigger_changelevel (0.5 0.5 0.5) ? NO_INTERMISSION
  333. When the player touches this, he gets sent to the map listed in the "map" variable.  Unless the NO_INTERMISSION flag is set, the view will go to the info_intermission spot and display stats.
  334. */
  335. void() trigger_changelevel =
  336. {
  337.     if (!self.map)
  338.         objerror ("chagnelevel trigger doesn't have map");
  339.     
  340.     InitTrigger ();
  341.     self.touch = changelevel_touch;
  342. };
  343.  
  344.  
  345. /*
  346. =============================================================================
  347.  
  348.                 PLAYER GAME EDGE FUNCTIONS
  349.  
  350. =============================================================================
  351. */
  352.  
  353. void() set_suicide_frame;
  354.  
  355. // called by ClientKill and DeadThink
  356. void() respawn =
  357. {
  358.     if (coop)
  359.     {
  360.         // make a copy of the dead body for appearances sake
  361.         CopyToBodyQue (self);
  362.         // get the spawn parms as they were at level start
  363.         setspawnparms (self);
  364.         // respawn        
  365.                 PutClientInServer ();
  366.     }
  367.     else if (deathmatch)
  368.     {
  369.         // make a copy of the dead body for appearances sake
  370.         CopyToBodyQue (self);
  371.         // set default spawn parms
  372.         SetNewParms ();
  373.         // respawn        
  374.         PutClientInServer ();
  375.     }
  376.     else
  377.     {    // restart the entire server
  378.         localcmd ("restart\n");
  379.     }
  380. };
  381.  
  382.  
  383. /*
  384. ============
  385. ClientKill
  386.  
  387. Player entered the suicide command
  388. ============
  389. */
  390. void() ClientKill =
  391. {
  392.     bprint (self.netname);
  393.     bprint (" suicides\n");
  394.     set_suicide_frame ();
  395.     self.modelindex = modelindex_player;
  396.     self.frags = self.frags - 2;    // extra penalty
  397.     respawn ();
  398. };
  399.  
  400. float(vector v) CheckSpawnPoint =
  401. {
  402.     return FALSE;
  403. };
  404.  
  405. /*
  406. ============
  407. SelectSpawnPoint
  408.  
  409. Returns the entity to spawn at
  410. ============
  411. */
  412. entity() SelectSpawnPoint =
  413. {
  414.     local    entity spot;
  415.     
  416. // testinfo_player_start is only found in regioned levels
  417.     spot = find (world, classname, "testplayerstart");
  418.     if (spot)
  419.         return spot;
  420.         
  421. // choose a info_player_deathmatch point
  422.     if (coop)
  423.     {
  424.         lastspawn = find(lastspawn, classname, "info_player_coop");
  425.         if (lastspawn == world)
  426.             lastspawn = find (lastspawn, classname, "info_player_start");
  427.         if (lastspawn != world)
  428.             return lastspawn;
  429.     }
  430.     else if (deathmatch)
  431.     {
  432.         lastspawn = find(lastspawn, classname, "info_player_deathmatch");
  433.         if (lastspawn == world)
  434.             lastspawn = find (lastspawn, classname, "info_player_deathmatch");
  435.         if (lastspawn != world)
  436.             return lastspawn;
  437.     }
  438.  
  439.     if (serverflags)
  440.     {    // return with a rune to start
  441.         spot = find (world, classname, "info_player_start2");
  442.         if (spot)
  443.             return spot;
  444.     }
  445.     
  446.     spot = find (world, classname, "info_player_start");
  447.     if (!spot)
  448.         error ("PutClientInServer: no info_player_start on level");
  449.     
  450.     return spot;
  451. };
  452.  
  453. /*
  454. ===========
  455. PutClientInServer
  456.  
  457. called each time a player is spawned
  458. ============
  459. */
  460. void() DecodeLevelParms;
  461. void() PlayerDie;
  462. void() PutClientInServer =
  463. {
  464.     local    entity spot;
  465.  
  466.     self.classname = "player";
  467.     self.health = 100;
  468.     self.takedamage = DAMAGE_AIM;
  469.     self.solid = SOLID_SLIDEBOX;
  470.     self.movetype = MOVETYPE_WALK;
  471.     self.show_hostile = 0;
  472.     self.max_health = 100;
  473.     self.flags = FL_CLIENT;
  474.     self.air_finished = time + 12;
  475.     self.dmg = 2;           // initial water damage
  476.     self.super_damage_finished = 0;
  477.     self.radsuit_finished = 0;
  478.     self.invisible_finished = 0;
  479.     self.invincible_finished = 0;
  480.     self.effects = 0;
  481.         self.invincible_time = 0;
  482.         self.alive = TRUE;
  483.  
  484.     DecodeLevelParms ();
  485.     
  486.     W_SetCurrentAmmo ();
  487.  
  488. // Magic stuff
  489.         self.mana = time - self.init_mana;
  490.         self.spell = 24;
  491.         self.splevel = 1;
  492.         self.controller = world;
  493.         self.enemy = world;
  494.         self.active = 2;
  495.     self.attack_finished = time;
  496.     self.th_pain = player_pain;
  497.     self.th_die = PlayerDie;
  498.         self.mass = 1;
  499.     self.touch = PlayerTouch;
  500.     
  501.     self.deadflag = DEAD_NO;
  502. // paustime is set by teleporters to keep the player from moving a while
  503.     self.pausetime = 0;
  504.     
  505.     spot = SelectSpawnPoint ();
  506.  
  507.     self.origin = spot.origin + '0 0 1';
  508.     self.angles = spot.angles;
  509.     self.fixangle = TRUE;        // turn this way immediately
  510.  
  511. // oh, this is a hack!
  512.         setmodel (self, "progs/eyes.mdl");
  513.     modelindex_eyes = self.modelindex;
  514.  
  515.         setmodel (self, "progs/dog.mdl");
  516.         modelindex_dog = self.modelindex;
  517.  
  518.         setmodel (self, "progs/player.mdl");
  519.     modelindex_player = self.modelindex;
  520.  
  521.     setsize (self, VEC_HULL_MIN, VEC_HULL_MAX);
  522.  
  523.         self.view_ofs = '0 0 22';
  524.  
  525.     player_stand1 ();
  526.     
  527.     if (deathmatch || coop)
  528.     {
  529.         makevectors(self.angles);
  530.         spawn_tfog (self.origin + v_forward*20);
  531.     }
  532.  
  533.     spawn_tdeath (self.origin, self);
  534. };
  535.  
  536.  
  537.  
  538.  
  539. /*
  540. =============================================================================
  541.  
  542.                 QUAKED FUNCTIONS
  543.  
  544. =============================================================================
  545. */
  546.  
  547.  
  548. /*QUAKED info_player_start (1 0 0) (-16 -16 -24) (16 16 24)
  549. The normal starting point for a level.
  550. */
  551. void() info_player_start =
  552. {
  553. };
  554.  
  555.  
  556. /*QUAKED info_player_start2 (1 0 0) (-16 -16 -24) (16 16 24)
  557. Only used on start map for the return point from an episode.
  558. */
  559. void() info_player_start2 =
  560. {
  561. };
  562.  
  563.  
  564. /*
  565. saved out by quaked in region mode
  566. */
  567. void() testplayerstart =
  568. {
  569. };
  570.  
  571. /*QUAKED info_player_deathmatch (1 0 1) (-16 -16 -24) (16 16 24)
  572. potential spawning position for deathmatch games
  573. */
  574. void() info_player_deathmatch =
  575. {
  576. };
  577.  
  578. /*QUAKED info_player_coop (1 0 1) (-16 -16 -24) (16 16 24)
  579. potential spawning position for coop games
  580. */
  581. void() info_player_coop =
  582. {
  583. };
  584.  
  585. /*
  586. ===============================================================================
  587.  
  588. RULES
  589.  
  590. ===============================================================================
  591. */
  592.  
  593. void(entity c) PrintClientScore =
  594. {
  595.     if (c.frags > -10 && c.frags < 0)
  596.         bprint (" ");
  597.     else if (c.frags >= 0)
  598.     {
  599.         if (c.frags < 100)
  600.             bprint (" ");
  601.         if (c.frags < 10)
  602.             bprint (" ");
  603.     }
  604.     bprint (ftos(c.frags));
  605.     bprint (" ");
  606.     bprint (c.netname);
  607.     bprint ("\n");
  608. };
  609.  
  610. void() DumpScore =
  611. {
  612.     local entity    e, sort, walk;
  613.  
  614.     if (world.chain)
  615.         error ("DumpScore: world.chain is set");
  616.  
  617. // build a sorted lis
  618.     e = find(world, classname, "player");
  619.     sort = world;
  620.     while (e)
  621.     {
  622.         if (!sort)
  623.         {
  624.             sort = e;
  625.             e.chain = world;
  626.         }
  627.         else
  628.         {
  629.             if (e.frags > sort.frags)
  630.             {
  631.                 e.chain = sort;
  632.                 sort = e;
  633.             }
  634.             else
  635.             {
  636.                 walk = sort;
  637.                 do
  638.                 {
  639.                     if (!walk.chain)
  640.                     {
  641.                         e.chain = world;
  642.                         walk.chain = e;
  643.                     }
  644.                     else if (walk.chain.frags < e.frags)
  645.                     {
  646.                         e.chain = walk.chain;
  647.                         walk.chain = e;
  648.                     }
  649.                     else
  650.                         walk = walk.chain;
  651.                 } while (walk.chain != e);
  652.             }
  653.         }
  654.         
  655.         e = find(e, classname, "player");
  656.     }
  657.  
  658. // print the list
  659.     
  660.     bprint ("\n");    
  661.     while (sort)
  662.     {
  663.         PrintClientScore (sort);
  664.         sort = sort.chain;
  665.     }
  666.     bprint ("\n");
  667. };
  668.  
  669. /*
  670. go to the next level for deathmatch
  671. */
  672. void() NextLevel =
  673. {
  674.     local entity o;
  675.  
  676. // find a trigger changelevel
  677.     o = find(world, classname, "trigger_changelevel");
  678.     if (!o || mapname == "start")
  679.     {    // go back to same map if no trigger_changelevel
  680.         o = spawn();
  681.         o.map = mapname;
  682.     }
  683.  
  684.     nextmap = o.map;
  685.     
  686.     if (o.nextthink < time)
  687.     {
  688.         o.think = execute_changelevel;
  689.         o.nextthink = time + 0.1;
  690.     }
  691. };
  692.  
  693. /*
  694. ============
  695. CheckRules
  696.  
  697. Exit deathmatch games upon conditions
  698. ============
  699. */
  700. void() CheckRules =
  701. {
  702.     local    float        timelimit;
  703.     local    float        fraglimit;
  704.     
  705.     if (gameover)    // someone else quit the game already
  706.         return;
  707.         
  708.     timelimit = cvar("timelimit") * 60;
  709.     fraglimit = cvar("fraglimit");
  710.     
  711.     if (timelimit && time >= timelimit)
  712.     {
  713. NextLevel ();
  714.         return;
  715.     }
  716.     
  717.     if (fraglimit && self.frags >= fraglimit)
  718.     {
  719. NextLevel ();
  720.         return;
  721.     }    
  722. };
  723.  
  724. //============================================================================
  725.  
  726. void() PlayerDeathThink =
  727. {
  728.     local entity    old_self;
  729.     local float        forward;
  730.  
  731.     if ((self.flags & FL_ONGROUND))
  732.     {
  733.         forward = vlen (self.velocity);
  734.         forward = forward - 20;
  735.         if (forward <= 0)
  736.             self.velocity = '0 0 0';
  737.         else    
  738.             self.velocity = forward * normalize(self.velocity);
  739.     }
  740.  
  741. // wait for all buttons released
  742.     if (self.deadflag == DEAD_DEAD)
  743.     {
  744.         if (self.button2 || self.button1 || self.button0)
  745.             return;
  746.         self.deadflag = DEAD_RESPAWNABLE;
  747.         return;
  748.     }
  749.  
  750. // wait for any button down
  751.     if (!self.button2 && !self.button1 && !self.button0)
  752.         return;
  753.  
  754.     self.button0 = 0;
  755.     self.button1 = 0;
  756.     self.button2 = 0;
  757.     respawn();
  758. };
  759.  
  760. void() Dog_JumpTouch;
  761.  
  762. void() PlayerJump =
  763. {
  764.         if (self.isfeign)       // experimental
  765.                 return;
  766.  
  767.      local vector start, end;
  768.     
  769.         if (self.levitime > time)
  770.                 {
  771.                 self.flags = self.flags + FL_INWATER;
  772.                 self.velocity = v_forward*180+v_up*60;
  773.                 return;
  774.                 }
  775.         if (self.flags & FL_WATERJUMP)
  776.         return;
  777.     
  778.         if (self.waterlevel >= 2)
  779.     {
  780.         if (self.watertype == CONTENT_WATER)
  781.                         self.velocity_z = 120/self.mass;
  782.         else if (self.watertype == CONTENT_SLIME)
  783.                         self.velocity_z = 110/self.mass;
  784.         else
  785.                         self.velocity_z = 100/self.mass;
  786. // play swiming sound
  787.                 if (self.swim_flag < time && self.waterlevel >= 2)
  788.         {
  789.             self.swim_flag = time + 1;
  790.             if (random() < 0.5)
  791.                 sound (self, CHAN_BODY, "misc/water1.wav", 1, ATTN_NORM);
  792.             else
  793.                 sound (self, CHAN_BODY, "misc/water2.wav", 1, ATTN_NORM);
  794.         }
  795.  
  796.         return;
  797.     }
  798.  
  799.         if (!(self.flags & FL_ONGROUND))
  800.         return;
  801.  
  802.         if ( !(self.flags & FL_JUMPRELEASED))
  803.         return;        // don't pogo stick
  804.  
  805.         self.flags = self.flags - (self.flags & FL_JUMPRELEASED);
  806.  
  807.     self.flags = self.flags - FL_ONGROUND;    // don't stairwalk
  808.     
  809.     self.button2 = 0;
  810. // player jumping sound
  811.         if (self.dog_time)
  812.         {
  813.                 makevectors (self.angles);
  814.                 self.origin_z = self.origin_z + 1;
  815.                 self.velocity = v_forward * 800 - '0 0 350';
  816.                 self.velocity_z = self.velocity_z * -1;
  817. //                if (self.flags & FL_ONGROUND)
  818. //                        self.flags = self.flags - FL_ONGROUND;
  819.                 sound (self, CHAN_BODY, "dog/dsight.wav", 1, ATTN_NORM);
  820.                 self.touch = Dog_JumpTouch;
  821.                 play_dog_leap1();
  822.         }
  823.         else if (self.levitime < time) 
  824.         {
  825.                 sound (self, CHAN_BODY, "player/plyrjmp8.wav", 1, ATTN_NORM);
  826.                 self.velocity_z = self.velocity_z + 270;
  827.         }
  828. };
  829.  
  830. /*
  831. ===========
  832. WaterMove
  833.  
  834. ============
  835. */
  836. .float    dmgtime;
  837.  
  838. void() WaterMove =
  839. {
  840. //dprint (ftos(self.waterlevel));
  841.        if(self.skin==24&&self.pausetime<=time)
  842.                 self.skin = self.speed;        
  843.        if (self.movetype == MOVETYPE_NOCLIP)
  844.                return;
  845.        if (self.health < 0)
  846.                return;
  847.  
  848.         if((self.watertype == CONTENT_WATER||self.watertype==CONTENT_SLIME) && self.waterlevel == 3 && random() < 0.1&&self.air_finished<time+12&&self.suff!=1)
  849.     {
  850.                 DeathBubbles(1);
  851.     }
  852.  
  853.        if (self.waterlevel != 3&&self.suff==0)
  854.        {
  855.                if (self.air_finished < time&&self.suff!=1)
  856.                        sound (self, CHAN_VOICE, "player/gasp2.wav", 1, ATTN_NORM);
  857.                else if (self.air_finished < time + 9&&self.suff!=1)
  858.                        sound (self, CHAN_VOICE, "player/gasp1.wav", 1, ATTN_NORM);
  859.                if (self.air_finished < time + 12)
  860.                        {
  861.                        self.air_finished = time + 12;
  862.                        self.dmg = 2;
  863.                        }
  864.        }
  865.        if ((self.air_finished < time && self.waterlevel == 3&&self.suff!=1)||self.suff==2||(self.waterlevel!=3&&self.suff==1))
  866.        {       // drown!
  867.                if(self.pain_finished < time)
  868.                {
  869.                        self.dmg = self.dmg + 2;
  870.                        if (self.dmg > 15)
  871.                                self.dmg = 10;
  872.                        T_Damage (self, world, world, self.dmg);
  873.                        self.pain_finished = time + 1;
  874.                }
  875.        }
  876.        if (! (self.flags & FL_WATERJUMP) && self.levitime < time)
  877.         self.velocity = self.velocity - 0.8*self.waterlevel*frametime*self.velocity;
  878.  
  879.        else if (self.levitime > time)
  880.                 self.velocity = self.velocity + frametime*self.velocity;
  881.  
  882.         if (!self.waterlevel && self.levitime < time)
  883.     {
  884.         if (self.flags & FL_INWATER)
  885.         {    
  886.             // play leave water sound
  887.             sound (self, CHAN_BODY, "misc/outwater.wav", 1, ATTN_NORM);
  888.             self.flags = self.flags - FL_INWATER;
  889.         }
  890.         return;
  891.     }
  892.  
  893.         if (self.watertype == CONTENT_LAVA && self.firesistime < time)
  894.     {    // do damage
  895.         if (self.dmgtime < time)
  896.         {
  897.             if (self.radsuit_finished > time)
  898.                 self.dmgtime = time + 1;
  899.             else
  900.                 self.dmgtime = time + 0.2;
  901.  
  902.             T_Damage (self, world, world, 10*self.waterlevel);
  903.         }
  904.     }
  905.         else if (self.watertype == CONTENT_SLIME&&self.suff!=1)
  906.     {    // do damage
  907.         if (self.dmgtime < time && self.radsuit_finished < time)
  908.         {
  909.             self.dmgtime = time + 1;
  910.             T_Damage (self, world, world, 4*self.waterlevel);
  911.         }
  912.     }
  913.     
  914.         if ( !(self.flags & FL_INWATER))
  915.     {    
  916.  
  917. // player enter water sound
  918.  
  919.         if (self.watertype == CONTENT_LAVA)
  920.             sound (self, CHAN_BODY, "player/inlava.wav", 1, ATTN_NORM);
  921.         if (self.watertype == CONTENT_WATER)
  922.             sound (self, CHAN_BODY, "player/inh2o.wav", 1, ATTN_NORM);
  923.         if (self.watertype == CONTENT_SLIME)
  924.             sound (self, CHAN_BODY, "player/slimbrn2.wav", 1, ATTN_NORM);
  925.  
  926.         self.flags = self.flags + FL_INWATER;
  927.         self.dmgtime = 0;
  928.     }
  929. };
  930.  
  931. void() CheckWaterJump =
  932. {
  933.     local vector start, end;
  934.  
  935. // check for a jump-out-of-water
  936.     makevectors (self.angles);
  937.     start = self.origin;
  938.     start_z = start_z + 8; 
  939.     v_forward_z = 0;
  940.     normalize(v_forward);
  941.     end = start + v_forward*24;
  942.     traceline (start, end, TRUE, self);
  943.     if (trace_fraction < 1)
  944.     {    // solid at waist
  945.         start_z = start_z + self.maxs_z - 8;
  946.         end = start + v_forward*24;
  947.         self.movedir = trace_plane_normal * -50;
  948.         traceline (start, end, TRUE, self);
  949.         if (trace_fraction == 1)
  950.         {    // open at eye level
  951.             self.flags = self.flags | FL_WATERJUMP;
  952.             self.velocity_z = 225;
  953.             self.flags = self.flags - (self.flags & FL_JUMPRELEASED);
  954.             self.teleport_time = time + 2;    // safety net
  955.             return;
  956.         }
  957.     }
  958. };
  959.  
  960.  
  961. /*
  962. ================
  963. PlayerPreThink
  964.  
  965. Called every frame before physics are run
  966. ================
  967. */
  968. void() PlayerPreThink =
  969. {
  970.     local    float    mspeed, aspeed;
  971.     local    float    r;
  972.  
  973.     if (intermission_running)
  974.     {
  975.         IntermissionThink ();    // otherwise a button could be missed between
  976.         return;                    // the think tics
  977.     }
  978.  
  979.     if (self.view_ofs == '0 0 0')
  980.         return;        // intermission or finale
  981.  
  982.     makevectors (self.v_angle);        // is this still used
  983.  
  984.     CheckRules ();
  985.     WaterMove ();
  986.         if(self.bloodloss>0)
  987.                 {
  988.                 self.deathtype="bleed";
  989.                 Bleed();
  990.                 }
  991.  
  992.     if (self.waterlevel == 2)
  993.         CheckWaterJump ();
  994.  
  995.     if (self.deadflag >= DEAD_DEAD)
  996.     {
  997.         PlayerDeathThink ();
  998.         return;
  999.     }
  1000.     
  1001.     if (self.deadflag == DEAD_DYING)
  1002.         return;    // dying, so do nothing
  1003.  
  1004.     if (self.button2)
  1005.     {
  1006.         PlayerJump ();
  1007.     }
  1008.     else
  1009.         self.flags = self.flags | FL_JUMPRELEASED;
  1010.  
  1011. // teleporters can force a non-moving pause time    
  1012.     if (time < self.pausetime)
  1013.         self.velocity = '0 0 0';
  1014. };
  1015.     
  1016. /*
  1017. ================
  1018. CheckPowerups
  1019.  
  1020. Check for turning off powerups
  1021. ================
  1022. */
  1023. void(vector org, vector vel, float damage) SpawnBlood;
  1024. void() CheckPowerups =
  1025. {
  1026.     if (self.health <= 0)
  1027.         return;
  1028.  
  1029. // TeleEyes or HoloCam
  1030.         if (self.aflag == 666)
  1031.                 if (self.invisible_sound < time)
  1032.         {
  1033.             sound (self, CHAN_AUTO, "items/inv3.wav", 0.5, ATTN_IDLE);
  1034.             self.invisible_sound = time + ((random() * 3) + 1);
  1035.                         stuffcmd (self, "bf\n");
  1036.                 }
  1037.  
  1038. // invisibility
  1039.         if (self.invisible_finished)
  1040.     {
  1041. // sound and screen flash when items starts to run out
  1042.                 if (self.invisible_sound < time)
  1043.         {
  1044.             sound (self, CHAN_AUTO, "items/inv3.wav", 0.5, ATTN_IDLE);
  1045.             self.invisible_sound = time + ((random() * 3) + 1);
  1046.         }
  1047.  
  1048.  
  1049.                 if (self.invisible_finished < time + 3)
  1050.         {
  1051.             if (self.invisible_time == 1)
  1052.             {
  1053.                 sprint (self, "Ring of Shadows magic is fading\n");
  1054.                 stuffcmd (self, "bf\n");
  1055.                 sound (self, CHAN_AUTO, "items/inv2.wav", 1, ATTN_NORM);
  1056.                 self.invisible_time = time + 1;
  1057.             }
  1058.             
  1059.             if (self.invisible_time < time)
  1060.             {
  1061.                 self.invisible_time = time + 1;
  1062.                 stuffcmd (self, "bf\n");
  1063.             }
  1064.         }
  1065.  
  1066.         if (self.invisible_finished < time)
  1067.         {    // just stopped
  1068.             self.items = self.items - IT_INVISIBILITY;
  1069.             self.invisible_finished = 0;
  1070.             self.invisible_time = 0;
  1071.         }
  1072.         
  1073.     // use the eyes
  1074.         self.frame = 0;
  1075.         self.modelindex = modelindex_eyes;
  1076.     }
  1077.     else
  1078.         self.modelindex = modelindex_player;    // don't use eyes
  1079.  
  1080. // Dog Mode
  1081.         if (self.dog_finished)
  1082.     {
  1083. // sound and screen flash when items starts to run out
  1084.                 if (self.dog_finished < time + 3)
  1085.         {
  1086.                         if (self.dog_time == 1)
  1087.             {
  1088.                                 sprint (self, "You feel yourself reverting to humanness.\n");
  1089.                 stuffcmd (self, "bf\n");
  1090.                 sound (self, CHAN_AUTO, "items/protect2.wav", 1, ATTN_NORM);
  1091.                                 self.dog_time = time + 1;
  1092.             }
  1093.             
  1094.                         if (self.dog_time < time)
  1095.             {
  1096.                                 self.dog_time = time + 1;
  1097.                 stuffcmd (self, "bf\n");
  1098.             }
  1099.         }
  1100.         
  1101.                 if (self.dog_finished < time)
  1102.         {    // just stopped
  1103.                 // FIEND -- Turn into a person
  1104.                 self.modelindex = modelindex_player;
  1105.                 sound (self, CHAN_VOICE, "dog/ddeath.wav", 1, ATTN_NORM);
  1106.                 W_SetCurrentAmmo();
  1107.                 self.view_ofs = '0 0 22';
  1108.                 DogChange(self);
  1109.                 self.dog_time = 0;                
  1110.                 self.dog_finished = 0;
  1111.                 self.touch = PlayerTouch;
  1112.                 }
  1113.                 self.modelindex = modelindex_dog;
  1114.     }
  1115. // invincibility
  1116.     if (self.invincible_finished)
  1117.     {
  1118. // sound and screen flash when items starts to run out
  1119.         if (self.invincible_finished < time + 3)
  1120.         {
  1121.             if (self.invincible_time == 1)
  1122.             {
  1123.                 sprint (self, "Protection is almost burned out\n");
  1124.                 stuffcmd (self, "bf\n");
  1125.                 sound (self, CHAN_AUTO, "items/protect2.wav", 1, ATTN_NORM);
  1126.                 self.invincible_time = time + 1;
  1127.             }
  1128.             
  1129.             if (self.invincible_time < time)
  1130.             {
  1131.                 self.invincible_time = time + 1;
  1132.                 stuffcmd (self, "bf\n");
  1133.             }
  1134.         }
  1135.         
  1136.         if (self.invincible_finished < time)
  1137.         {    // just stopped
  1138.             self.items = self.items - IT_INVULNERABILITY;
  1139.             self.invincible_time = 0;
  1140.             self.invincible_finished = 0;
  1141.         }
  1142.         if (self.invincible_finished > time)
  1143.             self.effects = self.effects | EF_DIMLIGHT;
  1144.         else
  1145.             self.effects = self.effects - (self.effects & EF_DIMLIGHT);
  1146.     }
  1147.  
  1148. // super damage
  1149.     if (self.super_damage_finished)
  1150.     {
  1151.  
  1152. // sound and screen flash when items starts to run out
  1153.  
  1154.         if (self.super_damage_finished < time + 3)
  1155.         {
  1156.             if (self.super_time == 1)
  1157.             {
  1158.                 sprint (self, "Quad Damage is wearing off\n");
  1159.                 stuffcmd (self, "bf\n");
  1160.                 sound (self, CHAN_AUTO, "items/damage2.wav", 1, ATTN_NORM);
  1161.                 self.super_time = time + 1;
  1162.             }      
  1163.             
  1164.             if (self.super_time < time)
  1165.             {
  1166.                 self.super_time = time + 1;
  1167.                 stuffcmd (self, "bf\n");
  1168.             }
  1169.         }
  1170.  
  1171.         if (self.super_damage_finished < time)
  1172.         {    // just stopped
  1173.             self.items = self.items - IT_QUAD;
  1174.             self.super_damage_finished = 0;
  1175.             self.super_time = 0;
  1176.         }
  1177.         if (self.super_damage_finished > time)
  1178.             self.effects = self.effects | EF_DIMLIGHT;
  1179.         else
  1180.             self.effects = self.effects - (self.effects & EF_DIMLIGHT);
  1181.     }    
  1182.  
  1183. // suit    
  1184.     if (self.radsuit_finished)
  1185.     {
  1186.         self.air_finished = time + 12;        // don't drown
  1187.  
  1188. // sound and screen flash when items starts to run out
  1189.         if (self.radsuit_finished < time + 3)
  1190.         {
  1191.             if (self.rad_time == 1)
  1192.             {
  1193.                 sprint (self, "Air supply in Biosuit expiring\n");
  1194.                 stuffcmd (self, "bf\n");
  1195.                 sound (self, CHAN_AUTO, "items/suit2.wav", 1, ATTN_NORM);
  1196.                 self.rad_time = time + 1;
  1197.             }
  1198.             
  1199.             if (self.rad_time < time)
  1200.             {
  1201.                 self.rad_time = time + 1;
  1202.                 stuffcmd (self, "bf\n");
  1203.             }
  1204.         }
  1205.  
  1206.         if (self.radsuit_finished < time)
  1207.         {    // just stopped
  1208.             self.items = self.items - IT_SUIT;
  1209.             self.rad_time = 0;
  1210.             self.radsuit_finished = 0;
  1211.                         self.skin = self.speed;
  1212.         }
  1213.     }    
  1214.  
  1215. };
  1216.  
  1217.  
  1218. /*
  1219. ================
  1220. PlayerPostThink
  1221.  
  1222. Called every frame after physics are run
  1223. ================
  1224. */
  1225. void() PlayerPostThink =
  1226. {
  1227.     local    float    mspeed, aspeed;
  1228.     local    float    r;
  1229.  
  1230.     if (self.view_ofs == '0 0 0')
  1231.         return;        // intermission or finale
  1232.     if (self.deadflag)
  1233.         return;
  1234.         
  1235. // do weapon stuff
  1236.  
  1237.     W_WeaponFrame ();
  1238.  
  1239. // check to see if player landed and play landing sound    
  1240.         if ((self.jump_flag < -100) && (self.flags & FL_ONGROUND) && (self.health > 0))
  1241.     {
  1242. //                if (self.watertype == CONTENT_WATER)
  1243.                 if(self.ducking>=time)
  1244.                         self.jump_flag=self.jump_flag+(random()*150+100);
  1245.                 if (self.waterlevel > 2)
  1246.             sound (self, CHAN_BODY, "player/h2ojump.wav", 1, ATTN_NORM);
  1247.                 else if (self.jump_flag < -600)
  1248.         {
  1249.                         T_Damage (self, world, world,0-((self.jump_flag/3 + 175)*self.mass)); //do minimum 25 damage, multiplied by your mass 
  1250.             sound (self, CHAN_VOICE, "player/land2.wav", 1, ATTN_NORM);
  1251.             self.deathtype = "falling";
  1252.         }
  1253.                 else if (self.jump_flag < -400)
  1254.                         {
  1255.                         T_Damage (self, world, world,0-((self.jump_flag/10 + 35)*self.mass)); //do minimum 5 damage, multiplied by your mass
  1256.             sound (self, CHAN_VOICE, "player/land.wav", 1, ATTN_NORM);
  1257.             self.deathtype = "falling";
  1258.                         }
  1259.                 else if (self.jump_flag < -150)
  1260.                         sound (self, CHAN_VOICE, "weapons/stepstop.wav", 1, ATTN_NORM);
  1261.         self.jump_flag = 0;
  1262.     }
  1263.  
  1264.         if (!(self.flags & FL_ONGROUND) && self.levitime < time)
  1265.                 {
  1266.                 self.velocity_z = self.velocity_z - 3; //simulated gravity
  1267.                 if (self.velocity_z > 1000) self.velocity_z = 1000; // terminal velocity
  1268.                 self.jump_flag = self.velocity_z;// damage when hit
  1269.                 }
  1270.  
  1271.     CheckPowerups ();
  1272. };
  1273.  
  1274.  
  1275. /*
  1276. ===========
  1277. ClientConnect
  1278.  
  1279. called when a player connects to a server
  1280. ============
  1281. */
  1282. void() ClientConnect =
  1283. {
  1284.     bprint (self.netname);
  1285.     bprint (" entered the game\n");
  1286.     
  1287. // a client connecting during an intermission can cause problems
  1288.     if (intermission_running)
  1289.         ExitIntermission ();
  1290. };
  1291.  
  1292.  
  1293. /*
  1294. ===========
  1295. ClientDisconnect
  1296.  
  1297. called when a player disconnects from a server
  1298. ============
  1299. */
  1300. void() ClientDisconnect =
  1301. {
  1302.     if (gameover)
  1303.         return;
  1304.     // if the level end trigger has been activated, just return
  1305.     // since they aren't *really* leaving
  1306.  
  1307.     // let everyone else know
  1308.     bprint (self.netname);
  1309.     bprint (" left the game with ");
  1310.     bprint (ftos(self.frags));
  1311.     bprint (" frags\n");
  1312.     sound (self, CHAN_BODY, "player/tornoff2.wav", 1, ATTN_NONE);
  1313.     set_suicide_frame ();
  1314. };
  1315.  
  1316. /*
  1317. ===========
  1318. ClientObituary
  1319.  
  1320. called when a player dies
  1321. ============
  1322. */
  1323. void(entity targ, entity attacker) ClientObituary =
  1324. {
  1325.     local    float rnum;
  1326.     local    string deathstring, deathstring2;
  1327.     rnum = random();
  1328.  
  1329.         if (attacker.classname == "teledeath")
  1330.         {
  1331.             bprint (targ.netname);
  1332.             bprint (" was telefragged by ");
  1333.             bprint (attacker.owner.netname);
  1334.             bprint ("\n");
  1335.  
  1336.             attacker.owner.frags = attacker.owner.frags + 1;
  1337.             return;
  1338.         }
  1339.  
  1340.         if (attacker.classname == "teledeath2")
  1341.         {
  1342.             bprint ("Satan's power deflects ");
  1343.             bprint (targ.netname);
  1344.             bprint ("'s telefrag\n");
  1345.  
  1346.             targ.frags = targ.frags - 1;
  1347.             return;
  1348.         }
  1349.  
  1350.         if (attacker.classname == "player")
  1351.         {
  1352.                         if (targ == attacker)
  1353.             {
  1354.                 // killed self
  1355.                 attacker.frags = attacker.frags - 1;
  1356.                 bprint (targ.netname);
  1357.                 
  1358.                                 if (targ.weapon == 64)
  1359.                                 {
  1360.                                 if (targ.waterlevel > 1)
  1361.                                         {
  1362.                                                 bprint (" discharges into the water.\n");
  1363.                                                 return;
  1364.                                         }
  1365.                                 }
  1366.                                 if (targ.weapon > 15 && targ.weapon < 32)
  1367.                     bprint (" tries to put the pin back in\n");
  1368.                                 else if (rnum>0.4)
  1369.                     bprint (" becomes bored with life\n");
  1370.                 else
  1371.                     bprint (" checks if his weapon is loaded\n");
  1372.                 return;
  1373.             }
  1374.             else
  1375.             {
  1376.                 attacker.frags = attacker.frags + 1;
  1377.  
  1378.                 rnum = attacker.weapon;
  1379.                 if (rnum == IT_AXE)
  1380.                 {
  1381.                     deathstring = " was ax-murdered by ";
  1382.                     deathstring2 = "\n";
  1383.                 }
  1384.                 if (rnum == IT_SHOTGUN)
  1385.                 {
  1386.                     deathstring = " chewed on ";
  1387.                     deathstring2 = "'s boomstick\n";
  1388.                 }
  1389.                                 if (rnum == IT_SNIPERGUN)
  1390.                 {
  1391.                                         deathstring = " was sniped by ";
  1392.                                         deathstring2 = "!\n";
  1393.                 }
  1394.                 if (rnum == IT_SUPER_SHOTGUN)
  1395.                                 {
  1396.                     deathstring = " ate 2 loads of ";
  1397.                     deathstring2 = "'s buckshot\n";
  1398.                 }
  1399.                 if (rnum == IT_NAILGUN)
  1400.                 {
  1401.                     deathstring = " was nailed by ";
  1402.                     deathstring2 = "\n";
  1403.                 }
  1404.                 if (rnum == IT_SUPER_NAILGUN)
  1405.                 {
  1406.                     deathstring = " was punctured by ";
  1407.                     deathstring2 = "\n";
  1408.                 }
  1409.                                 if (rnum > 15 && rnum < 32)
  1410.                 {
  1411.                     deathstring = " eats ";
  1412.                     deathstring2 = "'s pineapple\n";
  1413.                     if (targ.health < -40)
  1414.                     {
  1415.                         deathstring = " was gibbed by ";
  1416.                         deathstring2 = "'s grenade\n";
  1417.                     }
  1418.                 }
  1419.                                 if (rnum > 31 && rnum < 64)
  1420.                 {
  1421.                     deathstring = " rides ";
  1422.                     deathstring2 = "'s rocket\n";
  1423.                     if (targ.health < -40)
  1424.                     {
  1425.                         deathstring = " was gibbed by ";
  1426.                         deathstring2 = "'s rocket\n" ;
  1427.                     }
  1428.                 }
  1429.                 if (rnum == IT_LIGHTNING)
  1430.                 {
  1431.                     deathstring = " accepts ";
  1432.                     if (attacker.waterlevel > 1)
  1433.                         deathstring2 = "'s discharge\n";
  1434.                     else
  1435.                         deathstring2 = "'s shaft\n";
  1436.                 }
  1437.                                 if (rnum == IT_LASERGUN)
  1438.                 {
  1439.                                         deathstring = " got zapped by ";
  1440.                                         deathstring2 = "!\n";
  1441.                 }
  1442.  
  1443.                 bprint (targ.netname);
  1444.                 bprint (deathstring);
  1445.                 bprint (attacker.netname);
  1446.                 bprint (deathstring2);
  1447.             }
  1448.             return;
  1449.         }
  1450.         else
  1451.         {
  1452.             targ.frags = targ.frags - 1;        // killed self
  1453.             rnum = targ.watertype;
  1454.  
  1455.             bprint (targ.netname);
  1456.             if (rnum == -3)
  1457.             {
  1458.                 if (random() < 0.5)
  1459.                     bprint (" sleeps with the fishes\n");
  1460.                 else
  1461.                     bprint (" sucks it down\n");
  1462.                 return;
  1463.             }
  1464.             else if (rnum == -4)
  1465.             {
  1466.                 if (random() < 0.5)
  1467.                     bprint (" gulped a load of slime\n");
  1468.                 else
  1469.                     bprint (" can't exist on slime alone\n");
  1470.                 return;
  1471.             }
  1472.                         else if (rnum == -5&&targ.firesistime<=time)
  1473.             {
  1474.                 if (targ.health < -15)
  1475.                 {
  1476.                     bprint (" burst into flames\n");
  1477.                     return;
  1478.                 }
  1479.                 if (random() < 0.5)
  1480.                     bprint (" turned into hot slag\n");
  1481.                 else
  1482.                     bprint (" visits the Volcano God\n");
  1483.                 return;
  1484.             }
  1485.  
  1486.             if (attacker.flags & FL_MONSTER)
  1487.             {
  1488.                                 if (attacker.classname == "grunt")//"monster_army")
  1489.                     bprint (" was shot by a Grunt\n");
  1490.                                 if (attacker.classname == "fiend")//"monster_demon1")
  1491.                     bprint (" was eviscerated by a Fiend\n");
  1492.                                 if (attacker.classname == "rottweiler")//"monster_dog")
  1493.                     bprint (" was mauled by a Rottweiler\n");
  1494.                                 if (attacker.classname == "enforcer")//"monster_enforcer")
  1495.                     bprint (" was blasted by an Enforcer\n");
  1496.                                 if (attacker.classname == "rotfish")//"monster_fish")
  1497.                     bprint (" was fed to the Rotfish\n");
  1498.                                 if (attacker.classname == "hell knight")//"monster_hell_knight")
  1499.                     bprint (" was slain by a Death Knight\n");
  1500.                                 if (attacker.classname == "knight")//"monster_knight")
  1501.                     bprint (" was slashed by a Knight\n");
  1502.                                 if (attacker.classname == "ogre")//"monster_ogre")
  1503.                     bprint (" was destroyed by an Ogre\n");
  1504.                                 if (attacker.classname == "monster_oldone")
  1505.                     bprint (" became one with Shub-Niggurath\n");
  1506.                                 if (attacker.classname == "vore")//"monster_shalrath")
  1507.                     bprint (" was exploded by a Vore\n");
  1508.                                 if (attacker.classname == "shambler")//"monster_shambler")
  1509.                     bprint (" was smashed by a Shambler\n");
  1510.                                 if (attacker.classname == "spawn")//"monster_tarbaby")
  1511.                     bprint (" was slimed by a Spawn\n");
  1512. //                                if (attacker.classname == "vomitus")//"monster_vomit")
  1513. //                                        bprint (" was vomited on by a Vomitus\n");
  1514.                                 if (attacker.classname == "scrag")//"monster_wizard")
  1515.                                         bprint (" was fragged by a Scrag\n");
  1516.                                 if (attacker.classname == "zombie")//"monster_zombie")
  1517.                     bprint (" joins the Zombies\n");
  1518.  
  1519.                 return;
  1520.             }
  1521.             if (attacker.classname == "explo_box")
  1522.             {
  1523.                 bprint (" blew up\n");
  1524.                 return;
  1525.             }
  1526.             if (attacker.solid == SOLID_BSP && attacker != world)
  1527.             {    
  1528.                 bprint (" was squished\n");
  1529.                 return;
  1530.             }
  1531.                         if (attacker.classname == "spell")
  1532.             {
  1533.                 targ.deathtype = "";
  1534.                                 bprint (" was destroyed by magic\n");
  1535.                 return;
  1536.             }
  1537.             if (targ.deathtype == "falling")
  1538.             {
  1539.                 targ.deathtype = "";
  1540.                 bprint (" fell to his death\n");
  1541.                 return;
  1542.             }
  1543.                         if(targ.deathtype == "bleed")
  1544.             {
  1545.                 targ.deathtype = "";
  1546.                                 bprint (" bled to death\n");
  1547.                 return;
  1548.             }
  1549.             if (attacker.classname == "trap_shooter" || attacker.classname == "trap_spikeshooter")
  1550.             {
  1551.                 bprint (" was spiked\n");
  1552.                 return;
  1553.             }
  1554.             if (attacker.classname == "fireball")
  1555.             {
  1556.                 bprint (" ate a lavaball\n");
  1557.                 return;
  1558.             }
  1559.             if (attacker.classname == "trigger_changelevel")
  1560.             {
  1561.                 bprint (" tried to leave\n");
  1562.                 return;
  1563.             }
  1564.  
  1565.             bprint (" died\n");
  1566.         }
  1567. };
  1568.  
  1569.